package com.frank.wechat.handler;

import com.frank.wechat.utils.MessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author Frank Zou
 * @version v0.0.1
 * @date 2024/2/21
 * @description
 */

@Slf4j
@Component
public class SubscribeMessageHandler implements WeChatMessageHandler{


    @Override
    public WeChatMessageTypeEnum getMessageType() {
        return WeChatMessageTypeEnum.SUBSCRIPTION;
    }

    @Override
    public String handle(Map<String, String > messageBody) {
        log.info("接收到订阅消息：{}", messageBody);
        String toUser = messageBody.get("ToUserName");
        String fromUser = messageBody.get("FromUserName");
        String replyContent = "感谢关注挽音阁，我是 Frank ，欢迎一起来学习！";
        return MessageUtil.assembleTextMessageContent(toUser, fromUser, replyContent);
    }
}
